package com;

import com.entity.User;
import com.handler.BaseMapper;
import com.handler.DataScope;
import com.handler.PageInfo;
import com.mapper.UserMapper;
import com.ymx.darling.bean.sql.BoundSql;
import com.ymx.darling.bean.sql.Statement;
import com.ymx.darling.dialect.page.Page;
import com.ymx.darling.intercept.ExecutorInterceptMethods;
import com.ymx.darling.intercept.ExecutorInterceptor;
import com.ymx.darling.intercept.InterceptManager;
import com.ymx.darling.intercept.Invocation;
import com.ymx.darling.mapper.EntityMapper;
import com.ymx.darling.mapper.proxy.DarlingProxyFactory;
import com.ymx.darling.session.Session;
import com.ymx.darling.session.SessionFactory;
import com.ymx.darling.session.SessionFactoryBuilder;
import com.ymx.darling.session.setting.QuerySetting;
import com.ymx.darling.wrapper.QueryWrapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {
    public static void main(String[] args) throws Exception {
        InterceptManager.registerExecutorInterceptor(new MyExecutorInterceptor());

        SessionFactory sessionFactory = SessionFactoryBuilder.build("darling.xml");

        try (Session session = sessionFactory.openSession()) {
            UserMapper userMapper = session.getMapper(UserMapper.class);
        }
        /*
            1. 将所有的方法实现 更改为AbstractMethod
            2. 使用@MethodProvider注解来标注方法实现

            解析mapper的method
                判断是否存在@MethodProvider
                判断是否存在@Select
         */

        /*
            2018 - 2020
            2020 - 2023


         */
    }

    @ExecutorInterceptMethods("queryList")
    private static class MyExecutorInterceptor implements ExecutorInterceptor {
        public Object intercept(Invocation invocation) throws Throwable {
            if (invocation.getMapperMethod().isAnnotationPresent(DataScope.class)) {
                System.out.println("数据权限拦截成功"+invocation.getMapperMethod().getName());
            }
            return invocation.proceed();
        }
    }
}
